package com.googlecode.wicketcharts.showcase.links;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;

import com.googlecode.wicketcharts.highcharts.HighChartContainer;
import com.googlecode.wicketcharts.highcharts.options.Options;

public class UpdateChartLink extends AjaxLink<Void> {

	private static final long serialVersionUID = 1L;

	private final HighChartContainer chartContainer;

	private final Options options;

	public UpdateChartLink(String id, HighChartContainer chartContainer,
			Options options) {
		super(id);
		this.chartContainer = chartContainer;
		this.options = options;
	}

	public HighChartContainer getChartContainer() {
		return chartContainer;
	}

	public Options getOptions() {
		return options;
	}

	@Override
	public void onClick(AjaxRequestTarget target) {
		chartContainer.setOptions(this.options);
		target.add(chartContainer);
	}

}
